<?php
/**
 * OA_Exceptions
 * override CI_Exceptions, add ajax process
 * 
 * $Id: OA_Exceptions.php 139 2011-09-24 17:13:40Z alpha1130@gmail.com $
 */

class OA_Exceptions extends CI_Exceptions
{

    public function show_error($heading, $message, $template = 'error_general', $status_code = 500)
    {
        // Judge ajax
        if(array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER)
        && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')
        {
            echo json_encode(array(
                'ret_code' => -1,
                'sys_time' => $_SERVER['REQUEST_TIME'],
                'message' => $message,
                'data' => array()
            )); 

            exit;
        }
        else
        {
            return parent::show_error($heading, $message, $template, $status_code);
        }
    }
}


/* End of file: OA_Exceptions.php */
/* Location: ./application/core/OA_Exceptions.php */
